<div id="searchresults">
<?php
include("functions.php");
$con = mysql_connect("localhost","root","root");
//$con = mysql_connect("mysql10.000webhost.com","a8616686_booksq","sparklingteam88");

if (!$con)
{
	die('Could not connect: ' . mysql_error());
}
mysql_select_db("booksquare",$con);

$queryString = security($_POST['queryString']);
$query = "SELECT  book_title,bookphoto_link FROM T_USER_BOOK A";
$query .= " INNER JOIN M_BOOK B ON A.book_id=B.book_id";
$query .= " INNER JOIN T_BOOK_PHOTO C ON C.user_book_id = A.user_book_id";
$query .= "  WHERE C.bookphoto_series = 1 and B.book_title LIKE '%" . $queryString . "%' or B.book_author LIKE '%" . $queryString . "%' ORDER BY A.book_id LIMIT 8";
$result = mysql_query($query)or die(mysql_error());
$num_row = mysql_num_rows($result);
while($row=mysql_fetch_array($result)){
	$url = "12665339_1336702984_book image.jpg";
	$url = $row[bookphoto_link];
	$description = "Much has changed since the first edition of Human-Computer Interaction was published. Ubiquitous computing and rich sensor-filled environments are finding their way out of the laboratory, not just into movies but also into our workplaces and homes. The computer has broken out of its plastic and glass bounds providing us with networked societies where personal computing devices from mobile phones to smart cards fill our pockets and electronic devices surround us at home and work. The web too has grown from a largely academic network into the hub of business and everyday lives. As the distinctions between the physical and the digital, and between work and leisure start to break down, human-computer interaction is also changing radically.";
	if(strlen($description) > 80) { 
		$description = substr($description, 0, 80) . "...";
	}
	echo "<div class='book_item'><a href='book_to_sell.php?title=$row[book_title]'><img src='images/upload/$url' alt='$row[book_title]' width='35' height='40' /><span class='searchheading'>'$row[book_title]</span><span>$description</span><div class='clear'></div></a></div>";
}

/*echo $row[book_title];// Is there a posted query string?
if(isset($_POST['queryString'])) {
	$queryString = security($_POST['queryString']);
	
	// Is the string length greater than 0?
	if(strlen($queryString) >0) {
		$query = $db->query("SELECT * FROM T_USER_BOOK u INNER JOIN M_BOOK b ON u.book_id = b.book_id WHERE book_title LIKE '%" . $queryString . "%' ORDER BY book_id LIMIT 8");
		
		if($query) {
			// While there are results loop through them - fetching an Object.
			
			// Store the category id
			$catid = 0;
			while ($result = $query ->fetch_object()) {
				if($result->cat_id != $catid) { // check if the category changed
					echo '<span class="category">'.$result->cat_name.'</span>';
					$catid = $result->cat_id;
				}
				echo '<a href="'.$result->url.'">';
				echo '<img src="search_images/'.$result->img.'" alt="" />';
				
				$name = $result->book_title;
				if(strlen($name) > 35) { 
					$name = substr($name, 0, 35) . "...";
				}	         			
				echo '<span class="searchheading">'.$name.'</span>';
				
				$description = $result->book_author;
				if(strlen($description) > 80) { 
					$description = substr($description, 0, 80) . "...";
				}
				
				echo '<span>'.$description.'</span></a>';
			}
			echo '<span class="seperator"><a href="http://www.marcofolio.net/sitemap.html" title="Sitemap">Nothing interesting here? Try the sitemap.</a></span><br class="break" />';
		} else {
			echo 'ERROR: There was a problem with the query.';
		}
	} else {
		// Dont do anything.
	} // There is a queryString.
} else {
	echo 'There should be no direct access to this script!';
}	
*/

?>
<div class='clear'></div>
</div>